const session = require("koa-session");

const store = {
  storage: {},
  get(key) {
    // 从数据库获取
    return this.storage[key];
  },
  set(key, session) {
    this.storage[key] = session;
    // 存储到数据库
  },
  destroy(key) {
    delete this.storage[key];
    // 从数据库删除该 session
  },
};

module.exports = (app) => {
  app.keys = ['your-secret-key']; // 替换 'your-secret-key' 为一个安全的密钥
  return session({ store }, app);
};
